Skip to content

fix(cli): refuse to overwrite an existing project in uipath new - #2042

Open
rge-uipath wants to merge 7 commits into
mainfrom
fix/new-refuse-overwrite
Open

rge-uipath wants to merge 7 commits into
mainfrom
fix/new-refuse-overwrite

Conversation

@rge-uipath

@rge-uipath rge-uipath commented Dec 4, 2026 •

Copy link
Copy Markdown

uipath new <name> (function projects) silently replaced an existing main.py, pyproject.toml and uipath.json. Now, if any of them holds more than an unmodified uv init starter, nothing is written and it exits 1 via console.error, naming the files: "Run uipath new in an empty folder, or pass --force to overwrite." Agent-framework scaffolds are guarded separately (companion: UiPath/uipath-langchain-python#1268).

The documented quickstart (uv init . --python 3.11, uv add uipath, uipath new) still works. A pyproject.toml is replaceable when it holds only uv's [project] keys, uv's default version, description and readme, and at most a uipath or uipath>=X.Y.Z dependency. The starter of uv 0.12 and later is replaceable too: authors, one [project.scripts] entry <name> = "<module>:main" and a uv_build [build-system]. An extra, a pin or an edited requires-python is refused, and the src/<name>/__init__.py that uv wrote stays in place. The stub main.py that uv 0.11 and earlier write is replaceable when unchanged. Any uipath.json, or a dangling main.py/uipath.json symlink, is refused.

--force keeps the old in-place overwrite of all three files. It is not forwarded to agent-framework new middlewares: they take only name and live in other packages.

Tests: the existing-files test now asserts the refusal; new tests cover --force, a dangling symlink, the quickstart with and without uv's stub main.py, and refusal of a pyproject.toml with another dependency, tool config, an extra key, an edited version, description or readme, or invalid TOML, an edited stub main.py and an empty uipath.json. Patch version bumped to 2.15.17 (2.15.16 is on PyPI).

Verified from packages/uipath: uv run pytest tests/cli/test_new.py tests/cli/test_job_token.py tests/cli/eval/test_eval_util.py --no-cov, uv run ruff check, uv run ruff format, uv run mypy src/uipath/_cli/cli_new.py, and the real uipath new on folders from uv init with uv 0.9.30, 0.11.0 and 0.13.4.

🤖 Generated with Claude Code

Running `uipath new <name>` for a function project in a folder that already
had main.py, pyproject.toml or uipath.json silently replaced them. Exit 1
naming the existing files instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-runtime test:uipath-integrations labels Dec 4, 2026
rge-uipath and others added 2 commits December 3, 2026 17:07
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Only main.py and uipath.json mark an existing project. A pyproject.toml
alone (as written by uv init) is replaced as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@rge-uipath
rge-uipath marked this pull request as ready for review December 4, 2026 06:07
Copilot AI lite review requested due to automatic review settings December 4, 2026 06:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A moderate active finding remains because dangling symlinks can bypass the project-exists guard and allow scaffold files to be written despite the command’s no-overwrite promise.

1 open issue
What changed in this PR

Updates uipath new to protect existing function projects while preserving explicit overwrite behavior.

Changes:

  • Refuses overwrite when main.py or uipath.json exists.
  • Adds --force and tests for refusal, replacement, and bare pyproject.toml.
  • Bumps version to 2.15.16 and refreshes the lockfile.
File Description
packages/​uipath/​uv.lock Records the updated package version and lock metadata.
packages/​uipath/​tests/​cli/​test_new.py Covers project overwrite behavior.
packages/​uipath/​src/​uipath/​_cli/​cli_new.py Implements refusal and force handling.
packages/​uipath/​pyproject.toml Bumps the package version.

Review effort: Lite

@rliuup rliuup left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes because the documented uv init then uipath new quickstart now fails on uv releases that create main.py (head f920ffc), and check-version-availability is red since uipath==2.15.16 is already on PyPI, so this also needs a new patch version.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

🚨 Heads up: uipath-langchain cross-tests are FAILING 🚨

Your changes may break the uipath-langchain-python integration.

⚠️ These checks are NOT enforced by branch protection rules. Please review the failures before merging.

🔍 Inspect the failed run →

A pyproject.toml is replaced only when it holds uv's starter keys with uv's
default version, description and readme, and at most a uipath dependency, so a
configured project is refused before anything is written. The stub main.py that
uv 0.11 and earlier write counts as a starter too, so the documented uv init
quickstart works again. --force help now names pyproject.toml. Bump to 2.15.17,
since 2.15.16 is on PyPI.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@nikhil-maryala nikhil-maryala left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. No code blocker at 38255c1. Not run locally; reviewed from the diff.

Earlier comments, all addressed in this head:

  • My pyproject.toml comment: the no-force exception now covers only an unmodified uv init starter. Other deps, tool config, extra keys, edited values and invalid TOML are refused before any write. --force help now names pyproject.toml.
  • rliuup, uv stub main.py: an unchanged stub is replaceable. Version is 2.15.17, and 2.15.17 is not on PyPI yet.
  • Copilot, dangling symlink: os.path.lexists plus a test.

Checked: the guard runs before any file write. Exit code is 1 with a clear message that names the files and --force. Symlinked files are refused, even valid ones. Tests cover each refused case and --force.

Small findings, none blocking:

  • cli_new.py UV_STARTER_PROJECT_KEYS: authors is not allowed. If some uv versions add authors from git config, the quickstart would be refused. The author says real uv output was checked. Please confirm with a git-configured user. --force is the workaround.
  • cli_new.py _is_uv_starter: an empty or comment-only pyproject.toml counts as a starter. This is fine, only a note.
  • uv.lock: revision 3 to 5 and the exclude-newer lines are unrelated churn from a newer uv. Revert them if easy.
  • A write that fails halfway can still leave a partial scaffold. The pre-check does not cover this.
  • --force has no test for an existing uipath.json only.
  • CI: the triage-agent openai-agents jobs failed. They look unrelated to this diff, not checked.

@rliuup rliuup left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes because the documented uv init quickstart exits 1 at 38255c1 on current uv (0.13.13), and 2.15.17 would ship that.

uv 0.12 and later write authors, [project.scripts] and a uv_build [build-system], so the
documented quickstart exited 1. That unmodified starter is now replaced without --force.

The uipath dependency match is limited to what uv add writes (uipath or uipath>=X.Y.Z), so
an extra or a pin is kept. An edited requires-python is kept too. The lockfile holds only
the version change again.

Co-Authored-By: Claude <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Dec 5, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

🚨 Heads up: uipath-integrations cross-tests are FAILING 🚨

Your changes may break one or more integrations in uipath-integrations-python:

  • uipath-openai-agents
  • uipath-google-adk
  • uipath-agent-framework
  • uipath-llamaindex
  • uipath-pydantic-ai

⚠️ These checks are NOT enforced by branch protection rules. Please review the failures before merging.

🔍 Inspect the failed run →

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-integrations test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants